package com.chinaisafe.user.vo.request;

import com.chinaisafe.base.common.vo.request.PageReqVo;
import com.chinaisafe.base.common.validated.AddGroup;
import com.chinaisafe.base.common.validated.UpdateGroup;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
import com.chinaisafe.user.entity.SysMenu;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;

/**
 * SysMenuReqVO
 * Description：菜单(资源)请求值对象
 *
 * @author tby
 * @date  2024-07-11 17:32:41
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysMenuReqVO", description = "菜单(资源)请求值对象")
public class SysMenuReqVO extends PageReqVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    @NotNull(groups = UpdateGroup.class, message = "主键id不能为空" )
    private Long id;

    @Schema(description = "乐观锁版本")
    private Integer version;

    @Schema(description = "系统资源模块_id")
    @NotNull(groups = {AddGroup.class}, message = "系统资源模块id不能为空" )
    private Long sysModuleId;

    @Schema(description = "名称")
    @NotBlank(groups = {AddGroup.class}, message = "名称不能为空" )
    private String title;

    @Schema(description = "所属应用id")
    @NotBlank(groups = {AddGroup.class}, message = "所属应用id不能为空" )
    private Long sysAppId;

    @Schema(description = "是否缓存路由")
    private Boolean keepAlive;

    @Schema(description = "是否为常量路由")
    private Boolean constant;

    @Schema(description = "编码")
    private String name;

    @Schema(description = "父级id")
    private Long parentId;

    @Schema(description = "外部链接")
    private String href;

    @Schema(description = "路由地址")
    private String path;

    @Schema(description = "组件")
    private String component;

    @Schema(description = "是否外链")
    private Boolean frame;

    @Schema(description = "菜单类型")
    private String type;

    @Schema(description = "显示顺序")
    private Integer seq;

    @Schema(description = "激活菜单")
    private String activeMenu;

    @Schema(description = "是否显示")
    private Boolean hideInMenu;

    @Schema(description = "是否固定标签页")
    private Boolean fixedIndexInTab;

    @Schema(description = "是否多标签页")
    private Boolean multiTab;

    @Schema(description = "菜单图标")
    private String icon;

    @Schema(description = "请求参数")
    private String query;

    @Schema(description = "是否启用")
    private Boolean enable;


    /**
     * 将请求值对象装换为实体
     * @return SysMenu
     * @author tby
     * @date 2024-07-11 17:32:41
     */
    public SysMenu convertToEntity() {
        SysMenu entity = new SysMenu();
        entity.setId(this.id);
        entity.setVersion(this.version);
        // 给实体对应的字段赋值 可根据实际业务删减
        entity.setSysModuleId(this.sysModuleId);
        entity.setTitle(this.title);
        entity.setSysAppId(this.sysAppId);
        entity.setKeepAlive(this.keepAlive);
        entity.setConstant(this.constant);
        entity.setName(this.name);
        entity.setParentId(this.parentId);
        entity.setHref(this.href);
        entity.setPath(this.path);
        entity.setComponent(this.component);
        entity.setFrame(this.frame);
        entity.setType(this.type);
        entity.setSeq(this.seq);
        entity.setActiveMenu(this.activeMenu);
        entity.setHideInMenu(this.hideInMenu);
        entity.setFixedIndexInTab(this.fixedIndexInTab);
        entity.setMultiTab(this.multiTab);
        entity.setIcon(this.icon);
        entity.setQuery(this.query);
        entity.setEnable(this.enable);
        return entity;
    }
}
